<template>
	<el-dialog title="信息处理反馈" v-model="visible" customClass="customWidth" destroy-on-close @closed="$emit('closed')">
		<el-form :model="form" :rules="rules" ref="dialogForm" label-width="100px" label-position="left">
			<el-form-item label="信息标题">
				{{ info.title }}
			</el-form-item>
			<el-row :gutter="24">
				<el-col :lg="12">
					<el-form-item label="信息类型">
						{{ info.dataTypeName }}
					</el-form-item>
				</el-col>
				<el-col :lg="12">
					<el-form-item label="处理方式">
						{{ info.approvedTypeName }}
					</el-form-item>
				</el-col>
			</el-row>
			<el-row :gutter="24">
				<el-col :lg="12">
					<el-form-item label="上报部门">
						{{ info.deptName }}
					</el-form-item>
				</el-col>
				<el-col :lg="12">
					<el-form-item label="上报人">
						{{ info.fromUserName }}
					</el-form-item>
				</el-col>
			</el-row>
			<el-row :gutter="24">
				<el-col :lg="12">
					<el-form-item label="信息处理人">
						{{ info.approvedUserName }}
					</el-form-item>
				</el-col>
				<el-col :lg="12">
					<el-form-item label="上报时间">
						{{ info.sendTime }}
					</el-form-item>
				</el-col>
			</el-row>
			<el-form-item label="信息内容">
				<div v-html="info.content"></div>
			</el-form-item>
			<el-form-item label="相关附件" prop="attachId">
				<attach-menu :attachIds="info.attachId" :roleFlag="3" :preview="true"></attach-menu>
			</el-form-item>
			<el-divider>处理结果</el-divider>
			<el-form-item label="处理意见">
				<el-input v-model="form.content" placeholder="处理意见" maxlength="400" clearable type="textarea"></el-input>
			</el-form-item>
			<el-form-item label="相关附件" prop="attachId">
				<sc-upload-file :apiObj="apiObj" v-model="fileList" :data="{module:'datainfoattach'}" showFileList="false" @success="addNewFile">
					<el-button type="primary" icon="el-icon-upload">上传附件</el-button>
				</sc-upload-file>
				<attach-menu v-model:attachIds="form.attachId" :roleFlag="4" :preview="true"></attach-menu>
			</el-form-item>
		</el-form>
		<template #footer>
			<el-button @click="visible=false">取 消</el-button>
			<el-button v-if="mode!='show'" type="primary" :loading="isSaveing" @click="submit()">保 存</el-button>
		</template>
	</el-dialog>

</template>
<script>
import AttachMenu from '@/views/module/attachMenu'
export default {
	emits: ['success', 'closed'],
	components: {
		AttachMenu,
	},
	data() {
		return {
			visible: false,
			isSaveing: false,
			isShowMsg: false,
			fileList: [],
			apiObj: this.$API.file.attach.uploadFile,
			form:{
				recordId: '',
				content:'',
				attachId:''
			},
			info: {
				dataTypeName: '',
				approvedTypeName: '',
				approvedUserName: '',
				title: '',
				dataType: '',
				approvedType: '',
				deptId: '',
				deptName:'',
				fromAccountId: '',
				fromUserName:'',
				approvedUser: '',
				sendTime: '',
				toUser: '',
				content: '',
				attachId: '',
				msgType: ''
			}
		}
	},
	mounted() {
	},
	methods: {
		//显示
		open() {
			this.visible = true;
			return this
		},
		submit() {
			this.$refs.dialogForm.validate(async (valid) => {
				if (valid) {
					this.isSaveing = true;
					var res = await this.$API.info.uploadData.insertDataUploadHandle.post(this.form);
					this.isSaveing = false;
					if (res.code == 200) {
						this.$emit('success')
						this.visible = false;
						this.$message.success("操作成功")
					} else {
						this.$alert(res.message, "提示", {type: 'error'})
					}
				}
			})
		},
		setData(data) {
			this.form.recordId = data.recordId
			this.info.title = data.title
			this.info.dataTypeName = data.dataTypeName
			this.info.approvedTypeName = data.approvedTypeName
			this.info.approvedUserName = data.approvedUserName
			this.info.dataType = data.dataType
			this.info.approvedType = data.approvedType
			this.info.deptId = data.deptId
			this.info.deptName = data.deptName
			this.info.fromAccountId = data.fromAccountId
			this.info.approvedUser = data.approvedUser
			this.info.fromUserName =  data.fromUserName
			this.info.sendTime = data.sendTime
			this.info.toUser = data.toUser
			this.info.content = data.content
			this.info.attachId = data.attachId
			this.info.msgType = data.msgType
		},
		addNewFile(res, file)
		{
			let tArr =[];
			if(this.form.attachId!=undefined&&this.form.attachId!=null&&this.form.attachId!=''){
				tArr = this.form.attachId.split(",");
			}
			tArr.push(res.data.attachId);
			this.form.attachId = tArr.join(",");
		},
	}
}
</script>

<style>
.customWidth {
	width: 60%;
}
</style>
